comment |
 This is a short memory-resident (TSR) program which lets DOS,
 ANSI.SYS, and all of your programs use the entire 101-key 
 keyboard.  However, see warnings about its use in the text.
 Save as: 101KEY.ASM
 Compile: MASM 101KEY;
          LINK 101KEY;		(Ignore no-stack warning)
	  EXE2BIN 101KEY.EXE 101KEY.COM
	|

cseg	segment
	assume cs:cseg, ds:nothing
		org	100h			;.COM file format
start:		jmp	begin

old16		equ 	this dword		;Storage for prior Int 16
old16_off	dw	?
old16_seg	dw	?

new16:		pushf				;Save the flags
		cmp	ah,1			;Service 0 or 1?
		ja	leave			;No -- go
		or	ah,10h			;Change 0,1 to 10,11
leave:		popf				;Restore flags
		jmp	cs:old16		;Call original Int 16h
TSR_END		equ	$

CR		equ	13
LF		equ	10
signon		db	'DOS, ANSI.SYS, and all of your programs now',CR,LF
		db	'have access to all keys on your keyboard.$'
nobios		db	'101/102-key keyboard and BIOS support are ',CR,LF
		db	'required for this program.  TSR not installed.$'
dos4		db	'This program is unnecessary with DOS 4.x',CR,LF
		db	'TSR not installed.$'
dos1		db	'You must have DOS 2.x or 3.x to use this program$'

	assume cs:cseg, ds:cseg
begin:		mov	ax,40h			;BIOS data segment
		mov	es,ax			;ES ==> BIOS data
		test	byte ptr es:[96h],10h	;101-key kb installed?
		jnz	okay			;Yes -- go
		mov	dx,offset nobios	;No -- report error
error:		mov	ah,9			;DOS print string
		int	21h			;Call DOS
		int	20h			;Return to DOS
okay:		mov	ah,30h			;Get DOS version
		int	21h
		cmp	al,2			;At least 2.x?
		jae	@F			;Yes -- go
		mov	dx,offset dos1		;Else report error
		jmp	error			;  and leave
  @@:		cmp	al,4			;DOS 4?
  		jb	@F			;No -- it's okay
		mov	dx,offset dos4		;Else report error
		jmp	error			;  and leave
  @@:		mov	ax,3516h		;Get Int 16h vector
  		int	21h			;  from DOS
		mov	[old16_off],bx		;Save offset
		mov	[old16_seg],es		;  and segment
		mov	dx,offset new16		;DS:DX = new address
		mov	ax,2516h		;Set new Int 16 vector
		int	21h			;   with DOS
		mov	dx,offset signon	;Tell the world
		mov	ah,9			;   that everything's
		int	21h			;   okay.
		mov	dx,offset TSR_END	;Get address to keep
		int	27h			;Install TSR & exit
cseg		ends
		end	start

